/*
 * teek_client_constants.h
 *
 * macro declaration for libteec interface for kernel CA.
 *
 * Copyright (C) 2022 Huawei Technologies Co., Ltd.
 *
 * This software is licensed under the terms of the GNU General Public
 * License version 2, as published by the Free Software Foundation, and
 * may be copied, distributed, and modified under those terms.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 */

#ifndef TEEK_CLIENT_CONSTANTS_H
#define TEEK_CLIENT_CONSTANTS_H

enum global_service_cmd_id {
	GLOBAL_CMD_ID_INVALID = 0x0,
	GLOBAL_CMD_ID_BOOT_ACK = 0x1,
	GLOBAL_CMD_ID_OPEN_SESSION = 0x2,
	GLOBAL_CMD_ID_CLOSE_SESSION = 0x3,
	GLOBAL_CMD_ID_LOAD_SECURE_APP = 0x4,
	GLOBAL_CMD_ID_NEED_LOAD_APP = 0x5,
	GLOBAL_CMD_ID_REGISTER_AGENT = 0x6,
	GLOBAL_CMD_ID_UNREGISTER_AGENT = 0x7,
	GLOBAL_CMD_ID_REGISTER_NOTIFY_MEMORY = 0x8,
	GLOBAL_CMD_ID_UNREGISTER_NOTIFY_MEMORY = 0x9,
	GLOBAL_CMD_ID_INIT_CONTENT_PATH = 0xa,
	GLOBAL_CMD_ID_TERMINATE_CONTENT_PATH = 0xb,
	GLOBAL_CMD_ID_ALLOC_EXCEPTION_MEM = 0xc,
	GLOBAL_CMD_ID_TEE_TIME = 0xd,
	GLOBAL_CMD_ID_TEE_INFO = 0xe,
	GLOBAL_CMD_ID_REGISTER_LOG_MEM = 0xf,
	GLOBAL_CMD_ID_KILL_TASK = 0x10,
	GLOBAL_CMD_ID_TUI_EXCEPTION = 0x11,
	GLOBAL_CMD_ID_ADJUST_TIME = 0x12,
	GLOBAL_CMD_ID_SET_CA_HASH = 0x13,
	/* set the Android's build version */
	GLOBAL_CMD_ID_SET_BUILD_VERSION = 0x14,
	GLOBAL_CMD_ID_REGISTER_TTF_MEM = 0x15,
	/* get session key for encrypting dialog */
	GLOBAL_CMD_ID_GET_SESSION_SECURE_PARAMS = 0x16,
	GLOBAL_CMD_ID_REGISTER_MAILBOX = 0x17,
	GLOBAL_CMD_ID_REGISTER_UNUSUAL_TTF_MEM = 0x18,
	GLOBAL_CMD_ID_REGISTER_ION_MEM = 0x19,
	GLOBAL_CMD_ID_DUMP_MEMINFO = 0x1a,
	/* this cmd will be used to service no ca handle cmd */
	GLOBAL_CMD_ID_SET_SERVE_CMD = 0x1b,
	GLOBAL_CMD_ID_ADD_DYNAMIC_ION = 0x1c,
	GLOBAL_CMD_ID_DEL_DYNAMIC_ION = 0x1d,
	GLOBAL_CMD_ID_RELEASE_ION_SRV = 0x1e,
	/* this cmd for tui to get notch_size */
	GLOBAL_CMD_ID_TUI_NOTCH = 0x1f,
	GLOBAL_CMD_ID_LATE_INIT = 0x20,
	/* this cmd for tui to get information of foldable screen */
	GLOBAL_CMD_ID_TUI_FOLD = 0x21,
	GLOBAL_CMD_ID_GET_TEE_VERSION = 0x22,
#ifdef CONFIG_CMS_SIGNATURE
	GLOBAL_CMD_ID_UPDATE_TA_CRL = 0x23,
#endif
	GLOBAL_CMD_ID_REGISTER_RESMEM = 0x24,
	GLOBAL_CMD_ID_DUMP_SRV_SESS = 0x25,
	GLOBAL_CMD_ID_TRACE_ENABLE = 0x26,
#ifdef CONFIG_LIVEPATCH_ENABLE
	GLOBAL_CMD_ID_LIVEPATCH_UNLOAD = 0x27,
	GLOBAL_CMD_ID_LIVEPATCH_ENABLE = 0x28,
	GLOBAL_CMD_ID_LIVEPATCH_DISABLE = 0x29,
	GLOBAL_CMD_ID_LIVEPATCH_QUERY = 0x2a,
#endif
	GLOBAL_CMD_ID_UNKNOWN = 0x7FFFFFFE,
	GLOBAL_CMD_ID_MAX = 0x7FFFFFFF
};

enum teec_result {
	TEEC_SUCCESS = 0x0,
	TEEC_ERROR_INVALID_CMD = 0x1,
	TEEC_ERROR_SERVICE_NOT_EXIST = 0x2,
	TEEC_ERROR_SESSION_NOT_EXIST = 0x3,
	TEEC_ERROR_SESSION_MAXIMUM,
	TEEC_ERROR_REGISTER_EXIST_SERVICE,
	TEEC_ERROR_TAGET_DEAD_FATAL,
	TEEC_ERROR_READ_DATA,
	TEEC_ERROR_WRITE_DATA,
	TEEC_ERROR_TRUNCATE_OBJECT,
	TEEC_ERROR_SEEK_DATA,
	TEEC_ERROR_RENAME_OBJECT,
	TEEC_ERROR_TRUSTED_APP_LOAD_ERROR,
	TEEC_ERROR_GENERIC = 0xFFFF0000,
	TEEC_ERROR_ACCESS_DENIED = 0xFFFF0001,
	TEEC_ERROR_CANCEL = 0xFFFF0002,
	TEEC_ERROR_ACCESS_CONFLICT = 0xFFFF0003,
	TEEC_ERROR_EXCESS_DATA = 0xFFFF0004,
	TEEC_ERROR_BAD_FORMAT = 0xFFFF0005,
	TEEC_ERROR_BAD_PARAMETERS = 0xFFFF0006,
	TEEC_ERROR_BAD_STATE = 0xFFFF0007,
	TEEC_ERROR_ITEM_NOT_FOUND = 0xFFFF0008,
	TEEC_ERROR_NOT_IMPLEMENTED = 0xFFFF0009,
	TEEC_ERROR_NOT_SUPPORTED = 0xFFFF000A,
	TEEC_ERROR_NO_DATA = 0xFFFF000B,
	TEEC_ERROR_OUT_OF_MEMORY = 0xFFFF000C,
	TEEC_ERROR_BUSY = 0xFFFF000D,
	TEEC_ERROR_COMMUNICATION = 0xFFFF000E,
	TEEC_ERROR_SECURITY = 0xFFFF000F,
	TEEC_ERROR_SHORT_BUFFER = 0xFFFF0010,
	TEEC_PENDING = 0xFFFF2000,
	TEEC_PENDING2 = 0xFFFF2001,
	TEE_ERROR_TAGET_DEAD = 0xFFFF3024,
	TEE_ERROR_GT_DEAD = 0xFFFF3124,
	TEEC_ERROR_MAC_INVALID = 0xFFFF3071,
	TEEC_CLIENT_INTR = 0xFFFF4000,
	TEEC_ERROR_TUI_IN_USE = 0xFFFF7110,
	TEEC_ERROR_TUI_SWITCH_CHANNAL,
	TEEC_ERROR_TUI_CFG_DRIVER,
	TEEC_ERROR_TUI_INVALID_EVENT,
	TEEC_ERROR_TUI_POLL_EVENT,
	TEEC_ERROR_TUI_CANCELED,
	TEEC_ERROR_TUI_EXIT,
	TEEC_ERROR_TUI_NOT_AVAILABLE,
	TEEC_ERROR_SEC_FLASH_NOT_AVAILABLE,
	TEEC_ERROR_CA_AUTH_FAIL = 0xFFFFCFE5,
	TEE_ERROR_AUDIT_FAIL = 0xFFFF9112,
	TEE_ERROR_IS_DEAD = 0xFFFFABAB,
};

enum TEEC_ReturnCodeOrigin {
	TEEC_ORIGIN_API = 0x1,
	TEEC_ORIGIN_COMMS = 0x2,
	TEEC_ORIGIN_TEE = 0x3,
	TEEC_ORIGIN_TRUSTED_APP = 0x4,
};

enum TEEC_SharedMemCtl {
	TEEC_MEM_INPUT = 0x1,
	TEEC_MEM_OUTPUT = 0x2,
	TEEC_MEM_INOUT = 0x3,
};

enum TEEC_ParamType {
	TEEC_NONE = 0x0,
	TEEC_VALUE_INPUT = 0x01,
	TEEC_VALUE_OUTPUT = 0x02,
	TEEC_VALUE_INOUT = 0x03,
	TEEC_MEMREF_TEMP_INPUT = 0x05,
	TEEC_MEMREF_TEMP_OUTPUT = 0x06,
	TEEC_MEMREF_TEMP_INOUT = 0x07,
	TEEC_ION_INPUT = 0x08,
	TEEC_ION_SGLIST_INPUT = 0x09,
	TEEC_MEMREF_SHARED_INOUT = 0x0a,
	TEEC_MEMREF_WHOLE = 0xc,
	TEEC_MEMREF_PARTIAL_INPUT = 0xd,
	TEEC_MEMREF_PARTIAL_OUTPUT = 0xe,
	TEEC_MEMREF_PARTIAL_INOUT = 0xf
};

enum TEE_ParamType {
	TEE_PARAM_TYPE_NONE = 0x0,
	TEE_PARAM_TYPE_VALUE_INPUT = 0x1,
	TEE_PARAM_TYPE_VALUE_OUTPUT = 0x2,
	TEE_PARAM_TYPE_VALUE_INOUT = 0x3,
	TEE_PARAM_TYPE_MEMREF_INPUT = 0x5,
	TEE_PARAM_TYPE_MEMREF_OUTPUT = 0x6,
	TEE_PARAM_TYPE_MEMREF_INOUT = 0x7,
	TEE_PARAM_TYPE_ION_INPUT = 0x8,
	TEE_PARAM_TYPE_ION_SGLIST_INPUT = 0x9,
	TEE_PARAM_TYPE_MEMREF_SHARED_INOUT = 0x0a,
	TEE_PARAM_TYPE_RESMEM_INPUT = 0xc,
	TEE_PARAM_TYPE_RESMEM_OUTPUT = 0xd,
	TEE_PARAM_TYPE_RESMEM_INOUT = 0xe
};

enum TEEC_LoginMethod {
	TEEC_LOGIN_PUBLIC = 0x0,
	TEEC_LOGIN_USER,
	TEEC_LOGIN_GROUP,
	TEEC_LOGIN_APPLICATION = 0x4,
	TEEC_LOGIN_USER_APPLICATION = 0x5,
	TEEC_LOGIN_GROUP_APPLICATION = 0x6,
	TEEC_LOGIN_IDENTIFY = 0x7,
	TEEK_LOGIN_IDENTIFY = 0x80000001,
};

/* Add event id's name in 'view_state[]' in same order */
enum tee_event_id {
	INVOKE_CMD_START,
	INVOKE_CMD_END,
	SMC_SEND,
	SMC_DONE,
	SMC_IN,
	SMC_OUT,
	SMC_SLEEP,
	SMC_PREEMPT,
	GTASK_GET_CMD,
	GTASK_PUT_CMD,
	GTASK_REQ_TA,
	GTASK_RESP_TA,
	SPI_WAKEUP,
	SCHED_IN,
	SCHED_OUT,
	INTERRUPT_HANDLE_SPI_START,
	INTERRUPT_HANDLE_SPI_REE_RESPONSE,
	INTERRUPT_HANDLE_SPI_REE_MISS,
	INTERRUPT_HANDLE_SPI_REE_SCHEDULED,
	INTERRUPT_HANDLE_SPI_END,
	INTERRUPT_HANDLE_START,
	INTERRUPT_HANDLE_END,
	TEE_EVENT_MAX
};

#define TZ_WQ_MAX_ACTIVE 1
#endif
